const useDictStore = defineStore('dict', {
  state: () => ({
    dict: new Array(),
    statusBtnList: [
      { value: '1', label: '草稿' },
      { value: '2', label: '已提交' },
      { value: '3', label: '已完成' },
    ],
    statusList: [
      { value: '0', label: '草稿' },
      { value: '1', label: '审批中' },
      { value: '2', label: '已退回' },
      { value: '3', label: '不予立案' },
      { value: '4', label: '已撤案' },
      { value: '5', label: '已完成' },
      { value: '6', label: '已终止' },
    ],
    caseStatus: [
      { value: '1', label: '草稿' },
      { value: '2', label: '已提交' },
      { value: '3', label: '已立案' },
      { value: '4', label: '已结案' },
      { value: '5', label: '已撤案' },
      { value: '6', label: '不予立案' },
    ],
  }),
  actions: {
    // 获取字典
    getDict(_key) {
      if (_key == null && _key == '') {
        return null
      }
      try {
        for (let i = 0; i < this.dict.length; i++) {
          if (this.dict[i].key == _key) {
            return this.dict[i].value
          }
        }
      } catch (e) {
        return null
      }
    },
    // 设置字典
    setDict(_key, value) {
      if (_key !== null && _key !== '') {
        this.dict.push({
          key: _key,
          value: value,
        })
      }
    },
    // 删除字典
    removeDict(_key) {
      var bln = false
      try {
        for (let i = 0; i < this.dict.length; i++) {
          if (this.dict[i].key == _key) {
            this.dict.splice(i, 1)
            return true
          }
        }
      } catch (e) {
        bln = false
      }
      return bln
    },
    // 清空字典
    cleanDict() {
      this.dict = new Array()
    },
    // 初始字典
    initDict() {},
  },
})

export default useDictStore
